<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>钱包盒子-用户注册</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="../css/mui.css" />
		<link rel="stylesheet" href="../css/public.css" />
		<link rel="stylesheet" href="../css/login.css" />
	</head>

	<body class="bg-white">
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">手机快速注册</h1>
		</header>
		<div class="mui-content bg-white">
			<form class="login">
				<ul>
					<li class="layout-center">
						<div class="flex-item1">
							<input type="password" name="pass" id="password" placeholder="请设置6-20位的新密码" oninput="highliht(this);" onkeydown="highliht(this);" onkeyup="highliht(this);" />
						</div>
						<i class="icon-visual"></i>
					</li>
				</ul>
				<div class="btn-box2">
					<a href="javascript:void(0);" id="register" class="btn next-step disabled">注册</a>
				</div>
			</form>
		</div>
	</body>
	<script src="../js/mui.js" type="text/javascript" charset="utf-8"></script>
	<script src="../js/common.js" type="text/javascript" charset="utf-8"></script>
	<script>
		mui.init();
		var user_name,ems_code,send_ems_code;
		
		mui.plusReady(function() {
			var self = plus.webview.currentWebview();
			user_name = self.user_name;
			ems_code = self.ems_code;
			send_ems_code = self.send_ems_code;
		});
		
		
		//按钮是否可点
		function highliht(dom) {
			if(dom.value.length > 0 ){
				document.getElementById("register").classList.remove("disabled");
				document.getElementById("register").addEventListener('tap', send);
			}else{
				document.getElementById("register").classList.add("disabled");
			}
		}
		
		function send() {
			var user_pwd = document.getElementById("password").value;
			if(!user_pwd) {
				common.alert("提示", "请填写密码");
				return false;
			}
			var params = {
				url: 'Personal/register',
				data: {
					user_name: user_name,
					mobile: user_name,
					ems_code: ems_code,
					user_pwd: user_pwd,
					user_pwd2: user_pwd,
					send_ems_code: send_ems_code
				}
			}
			common.loading("注册中...请稍后...");
			common.JsonPost(params, function(data) {
				common.closeLoading();
				console.log(JSON.stringify(data));
				//用户
				common.setLocVal("userId", data.id);
				common.setLocVal("userName", data.user_name);
				common.setLocVal("realName", data.real_name);
				common.setLocVal("mobile", data.mobile);
				common.setLocVal("avatar", data.avatar);
				common.setLocVal("userData", JSON.stringify(data));
				//返回个人中心 并刷新个人中心页面
				setTimeout(function() {
					common.execScript("my", "init()");
				}, 100);
				common.closeWin("login");
				common.closeWin("reg");
				common.closeWin("reg_two");
				common.closeWin();
			})
		}
	</script>

</html>